﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace OpenLS.Spreadsheet.UI
{
    class ViewModelFactory: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return null;
            if (value is Worksheet)
            {
                Worksheet ws = (Worksheet) value;
                return WorksheetViewModel.GetModel(ws);
            }
            if (value is ConditionalFormattingRule)
            {
                return new ConditionalFormattingRuleViewModel((ConditionalFormattingRule) value);
            }
            if (value is Chartsheet)
            {
                return new ChartsheetViewModel((Chartsheet)value);
            }
            throw new NotImplementedException();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}